const path = require('path')
function resolve(dir) {
   return path.join(__dirname, dir)
}
const name = process.env.VUE_APP_BASE_TITLE || '我的Vue3'

module.exports = {
   publicPath: process.env.VUE_APP_BASE_URL,
   lintOnSave: false,
   devServer: {
      host: '0.0.0.0',
      port: 80,
      open: true,
      proxy: {
         [process.env.VUE_APP_BASE_API]: {
            pathRewrite: {
               ['^' + process.env.VUE_APP_BASE_API]: ''
            },
            target: `http://127.0.0.1:4523/m1/2401239-0-default`, // mock
            changeOrigin: true
         }
      },
      disableHostCheck: true
   },
   chainWebpack: config => {
      config.resolve.alias
         .set('@', resolve('src'))
      const svgRule = config.module.rule('svg')
      svgRule.exclude.add(resolve('src/assets/svg'))
      config
         .plugin('html')
         .tap(args => {
            args[0].title = name
            return args
         })
      config.module
         .rule('my-svg')
         .test(/\.(svg)(\?.*)?$/)
         .include
         .add(resolve('src/assets/svg'))
         .end()
         .use('svg-sprite-loader')
         .loader('svg-sprite-loader')
   },
   productionSourceMap: false
}